package com.zs.service.impl;

import com.zs.pojo.User;
import com.zs.service.Action;
import com.zs.utils.RequestToBean;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

/**
 * @author ZhouShuang
 * @version 17
 * @Title
 * @date 2025/6/11 上午9:41
 */
public class LoginAction implements Action {
    /**
     * @param request
     * @param response
     */
    @Override
    public void execute(HttpServletRequest request, HttpServletResponse response) throws Exception{
        User user  = RequestToBean.convert(User.class, request);
        HttpSession session = request.getSession();
        //登录成功后，将用户信息存入session
        session.setAttribute("user", user);
        System.out.println(user);
        response.getWriter().print("登录成功！");
    }
}
